//
//  UIButton+DF.m
//  九个头条
//
//  Created by HZ on 14-6-24.
//  Copyright (c) 2014年 cn.huiz. All rights reserved.
//

#import "UIButton+DF.h"



@implementation UIButton (DF)

- (id)initWithBackgroundImage:(NSString *)normal highlightedBackgroundImage:(NSString *)highlighted selectedBackgroundImage:(NSString*)selected disabledBackgroundImage:(NSString*)disabled target:(id)target action:(SEL)action {
    if(self = [super init]) {
        // 设置普通背景图片
        [self setBackgroundImage:[UIImage imageNamed:normal] forState:UIControlStateNormal];
        
        [self setBackgroundImage:[UIImage imageNamed:highlighted] forState:UIControlStateHighlighted];

        [self setBackgroundImage:[UIImage imageNamed:selected] forState:UIControlStateSelected];
        
        [self setBackgroundImage:[UIImage imageNamed:disabled] forState:UIControlStateDisabled];
        
        [self addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    return self;
}

-(void)setImageNameForStateNormal:(NSString *)normal highlighted:(NSString *)highlighted selected:(NSString *)selected disabled:(NSString *)disabled {
    [self setImageForStateNormal:[UIImage imageNamed:normal] highlighted:[UIImage imageNamed:highlighted] selected:[UIImage imageNamed:selected] disabled:[UIImage imageNamed:disabled]];
}

-(void)setBackgroundImageNameForStateNormal:(NSString *)normal highlighted:(NSString *)highlighted selected:(NSString *)selected disabled:(NSString *)disabled {
    [self setBackgroundImageForStateNormal:[UIImage imageNamed:normal] highlighted:[UIImage imageNamed:highlighted] selected:[UIImage imageNamed:selected] disabled:[UIImage imageNamed:disabled]];
}


-(void)setImageForStateNormal:(UIImage *)normal highlighted:(UIImage *)highlighted selected:(UIImage *)selected disabled:(UIImage *)disabled {
    [self setImage:normal forState:UIControlStateNormal];
    [self setImage:highlighted forState:UIControlStateHighlighted];
    [self setImage:selected forState:UIControlStateSelected];
    [self setImage:disabled forState:UIControlStateDisabled];
}


-(void)setBackgroundImageForStateNormal:(UIImage *)normal highlighted:(UIImage *)highlighted selected:(UIImage *)selected disabled:(UIImage *)disabled {
    [self setBackgroundImage:normal forState:UIControlStateNormal];
    [self setBackgroundImage:highlighted forState:UIControlStateHighlighted];
    [self setBackgroundImage:selected forState:UIControlStateSelected];
    [self setBackgroundImage:disabled forState:UIControlStateDisabled];
}

@end
